home *** CD-ROM | disk | FTP | other *** search
- /*
- * Gauge.psw, Postscript code for drawing analog gauge.
- * Author: Bruce Blumberg, NeXT Developer Support Group.
- * Originally written for 0.6 mid 1988, modified for 1.0 by Ali Ozer.
- * Cleaned and spiffed up for 2.0 by Julie Zelenski.
- * Took away the /mhand function since it didn't work for multiple
- * instances of the gauge (if they were different sizes). Also took most
- * of the setgray calls out so I could use color. Just the borders still
- * use grays (and it checks to make sure it is not the same gray as the
- * face is drawn in). February 26, 1995 by Todd Thomas.
- * You may freely copy, distribute and reuse the code in this example.
- * NeXT disclaims any warranty of any kind, expressed or implied, as to
- * its fitness for any particular use.
- * Thank you NeXT, I will take you up on that.
- */
-
-
- /* PSWdrawBorder draws the border and background of the gauge face.
- */
- defineps PSWdrawBorder(float x; float y; float radius)
- x y radius 1.5 add 0 360 arc
- fill
- 1.0 setlinewidth
- % if the current gray is white, then use light gray.
- currentgray 1.0 eq {0.333} {1.0} ifelse
- setgray
- x y radius 2 add 50 220 arc
- stroke
- 1.5 setlinewidth
- % if the current gray is dark gray, use light.
- currentgray 0.333 eq {0.667} {0.333} ifelse
- setgray
- x y radius 2 add 220 50 arc
- stroke
- 1.0 setlinewidth
- % if the current gray is black, use dark gray.
- currentgray 0.0 eq {0.333} {0.0} ifelse
- setgray
- x y radius 1.5 add 220 50 arc
- stroke
- endps
-
-
- /* PSWdrawTicks draws a tick mark at each increment around the circle
- * from the start to the stop angle.
- */
- defineps PSWdrawTicks(float x; float y; float radius; float increment; float start; float stop)
- .5 setlinewidth
- gsave
- x y translate
- start rotate
- start increment stop {
- newpath
- radius 0 moveto
- -3 0 rlineto
- closepath
- stroke
- increment neg rotate
- } for
- grestore
- endps
-
-
- /* PSWdrawString simply draws string at specific location
- */
- defineps PSWdrawString(float x; float y; char *str)
- x y moveto
- (str) show
- endps
-
-
- /* PSWdrawHand translate and rotates the coordinate system, then
- * draws the gauge hand.
- */
-
- defineps PSWdrawHand(float x; float y; float ang; float length)
- gsave
- x y translate
- ang rotate
-
- 0 setlinewidth
- newpath
- 0 3.5 moveto
- 0 0 3.5 90 270 arc
- length 3.5 rlineto
- length neg 3.5 rlineto
- closepath
- fill
- newpath
- 0 2 moveto
- 0 0 1.5 0 360 arc
- closepath
- 1.0 currentgray sub setgray
- closepath
- fill
-
- grestore
- endps
-
-
- /* For if we are drawing in a flipped view (a matrix perhaps). */
-
- defineps PSWflipme (float height)
-
- 1.0 -1.0 scale
- 0.0 height neg translate
-
- endps
-
-
-
-